<?php
require_once './application/core/CoreBase.php';

class writeAdm extends CoreBase
{
    private $_configPath;
    private $_config;
    private $_sonde;
    private $_server;
    private $_user;
    private $_pass;
    private $_database;
    private $_graphiz;
    private $_tmpPath;
    private $_writer;
    private $_option;


    public function writeIni()
    {
        $this->_server = $this->_controller->getRequest()->getParam('server');
        $this->_database = $this->_controller->getRequest()->getParam('db');
        $this->_user = $this->_controller->getRequest()->getParam('user');
        $this->_pass = $this->_controller->getRequest()->getParam('pass');
        $this->_graphiz = $this->_controller->getRequest()->getParam('graphiz');
        $this->_sonde = $this->_controller->getRequest()->getParam('sonde');
        $this->_tmpPath = $this->_controller->getRequest()->getParam('tmpPath');

        $this->_configPath = './application/configuration/config.ini';
        $this->_options['allowModifications'] = true;
        $this->_writer = new Zend_Config_Writer_Ini();
        $this->_config = new Zend_Config_Ini( $this->_configPath, null, $this->_options );
       
        $this->_config->database->database->params->host = $this->_server;
        $this->_config->database->database->params->username = $this->_user;
        $this->_config->database->database->params->password = $this->_pass;
        $this->_config->database->database->params->dbname = $this->_database;
        
        $this->_config->topologie->generation->pathTmp = $this->_tmpPath;
        $this->_config->topologie->graphviz->location = $this->_graphiz;
       
        $this->_config->sonde->sonde->location = $this->_sonde;
        $this->_writer->write($this->_configPath, $this->_config);

    }

}